<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ page import="java.sql.*,java.util.*,bean.*,dao.*,vo.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>选课信息查询</title>
</head>
<body bgcolor="aaaaff">
   
<center>
  <br><br><br>
  <br><br><br>
  <h2>查询选课信息</h2><br>
  <form action="lookCourse.jsp" method="post">
    <p>请选择学号：
      <select name="id">
        <%
         StudentDao sdao=new StudentDao();
          ArrayList stus=(ArrayList)sdao.getAllStudents();
          int i=0;
          while(i<stus.size()){
          		Student stu=(Student)stus.get(i);
        	  String SNo=stu.getStuno();
        	  i++;
        %>
        <option value="<%=SNo%>"><%=SNo %></option>
        <%
          }
        %> 
      </select>
    </p>
    <p>
    <input type="submit" value="确定">&nbsp;
    <input type="button" value="返回" onclick="javascript:history.go(-1)">    
    </p>
  </form>
  
</center>
    <%String id=request.getParameter("id");
    if(null!=id){
    CourseDao cdao=new CourseDao();
    ArrayList cous=(ArrayList)cdao.getCourseByStuno(id); 
    %> 
    <center>
	  <%=id %>号学生课程查询结果
	  <hr>
	  <table border="1" bgcolor="cccfff" align="center">
	   <tr>
	   	<td>序号</td>
	    <td>学号</td>
	    <td>姓名</td>
	    <td>课程号</td>
	    <td>课程名</td>
	    <td>学期</td>
	   </tr>
    <%for(i=0;i<cous.size();i++){
    	Course cou=(Course)cous.get(i);
    	String stuno=cou.getStuno();
    	String courseno=cou.getCourseno();
    	String stuname=cou.getStuname();
    	String coursename=cou.getCoursename();
    	String semester=cou.getSemester();
    %>	
    	<tr>
	   	<td><%=i+1 %></td>
	    <td><%=stuno %></td>
	    <td><%=stuname %></td>
	    <td><%=courseno %></td>
	    <td><%=coursename %></td>
	    <td><%=semester %></td>
	   </tr>
    <% }
     %>
    </table>
    </center>
    <% }
     %>
</body>
</html>